Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CUMULUS-3682 -- Update @cumulus/message.Granule to handle missing values in CMR metadata #3865

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Jkovarik
Copy link
Member

@Jkovarik Jkovarik commented Nov 20, 2024

This commit adds logic in convertDateToISOStringSettingNull to:

  • set '' as an expected null if encountered in any of the granule temporal fields handled by the Granules methods.
  • Handle explicit undefined values by returning them rather than attempting to date convert them (the error case for this ticket)

This update should be compatible with api granule write logic in that it's preserving the intent of implicit undefined values while allowing for explicit undefineds that weren't originally part of the expected typing coming from the CMR metadata spec.

Summary: Summary of changes

Addresses CUMULUS-3682

Changes

  • Detailed list or prose of changes
  • ...

PR Checklist

  • Update CHANGELOG
  • Unit tests
  • Ad-hoc testing - Deploy changes and test manually
  • Integration tests

This commit adds logic in convertDateToISOStringSettingNull to

- set '' as an expected null if encountered in any of the granule
temporal fields handled by the Granules methods.
- Handle explicit undefined values by returning them rather than
attempting to date convert them (the error case for this ticket)

This update should be compatible with api granule write logic in that
it's preserving the intent of implicit undefined values while allowing
for explicit undefineds that weren't originally part of the expected
typing coming from the CMR metadata spec.
@@ -46,7 +46,7 @@ export type ApiGranuleRecord = {
timestamp?: number
timeToArchive?: number
timeToPreprocess?: number
} & PartialGranuleTemporalInfo & ParitalGranuleProcessingInfo;
} & PartialGranuleTemporalInfo & PartialGranuleProcessingInfo;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

if (date === null) return null;
const convertDateToISOStringSettingNull = (date: string | null | undefined) => {
if (isNil(date)) return date;
if (date === '') return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good and is more explicit than something like if (!date) but is there a case here where just checking for a falsy value with !date falls down?

Copy link
Contributor

@npauzenga npauzenga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice @Jkovarik this looks very reasonable. I added a question about using your explicit checks vs. !date but that's mainly to ensure there's not a case here that needs to be explicitly tested.

Pre-emptively approving because I don't see where this might cause issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants